import oscP5.*;
import netP5.*;
import java.io.*;
import java.util.*;

/* map OSC controllers to user variables for sketches */
float oscX, oscY = 0.0;
float oscRot;

//! functional constants
float gm = 1.60;
float gr = 0.60;
PFont font;

//! OSC 
NetAddress AddPad; //for sending OSC messages to the ipad
OscP5 oscP5Multi; 
//OscP5 oscP5Echo; //the iPad controller
OscMessage echoMsg;
OscMessage multiMsg;

// hard code constants

String Domain = "192.168.1.";
String Pad= "68";
String Sim="78";

//arrays
IntList seqIndexList;


void InitFacetObjects() {
  //initialize facet objects, find indexes for addressing with OSC
  SeqList = new ArrayList();
  seqIndexList = new IntList();
  for (int i = 1;i< facets.length;i++) {
    //search by type
    if (facets[i][0].equals("seq")==true) {
      SeqList.add(new F_Seq(i, facets[i][2], int(facets[i][3])));
      seqIndexList.append(i);
      facets[i][1]=str(seqIndexList.size()-1);
      println("S:Img seq: "+facets[i][2]+" "+facets[i][1]);
    }
  }
}

void commonSetup() {
  OSCInit();
  LoadFacets();
  LoadPods();
  InitFacetObjects();
  /* former stuff
   InitSeed();
   */
  if (!androidMode) {
    HUDSetup();
  }
}

void OSCInit() {
  oscP5Multi = new OscP5(this, "239.0.0.1", 7777);
  //  oscP5Echo = new OscP5(this, 8000);  NO NO BAD, do not want two apps listening to this port 
  AddPad = new NetAddress(Domain+Pad, 9000);
}
